import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;

import gui.HeatPad;
import gui.UserControls;
import gui.Util;


/**
 * @author Team 3
 */
public class GUIPlate extends JFrame {
    private HeatPad heatPad;
    private UserControls userControls;
    private Container contentPane = getContentPane();
    private Icon img;
    
    /** Creates a new instance of GUIPlate */
    public GUIPlate() {
        super("Heat Simulation (alpha 0.3.4)");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(new Dimension(750, 600));
        contentPane.setLayout(new BorderLayout());
    }    
   
    private void createAndShowGUI() {
      try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
           
      //create and add widgets
      JPanel pnlMain = new JPanel(new BorderLayout());
      heatPad = new HeatPad();
      userControls = new UserControls(heatPad);

      pnlMain.add(heatPad, BorderLayout.CENTER);
      pnlMain.add(userControls, BorderLayout.EAST);
      img = Util.getImage("colorKey.JPG");
      //img = new ImageIcon("C:\\Classes\\CS 6310\\Project1\\src\\gui\\colorKey.jpg");
      JLabel colorKey = new JLabel(img);
      pnlMain.add(colorKey, BorderLayout.WEST);
      
      // Display the window.
      contentPane.add(pnlMain, BorderLayout.CENTER);
      //pack();
      setVisible(true);
      
    }
    
    public void showExampleGrid() {
        JFrame exampleFrame = new JFrame();
        JPanel example = new JPanel(new GridLayout(100,1));
        float RED_FACTOR = 2.5F; 
        
        for (int i = 1; i <= 100; i++) {
            int shadeOfRed = new Double(i * RED_FACTOR).intValue();
            for (int j = 1; j <= 1; j++) {
                JPanel b = new JPanel();
                b.setBackground(new Color(shadeOfRed, 0, 0));
                JLabel l = new JLabel(new Integer(i).toString());
                b.add(l);
                example.add(b);
            }
        }
        
        exampleFrame.add(example);
        exampleFrame.setVisible(true);
        
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new GUIPlate().createAndShowGUI();
            }
        });
    }    
}
